import { getArticleList, getArticleDetail } from 'api/activity'
const share = {
  state: {
    url: location.href,
    pageDes: {}
  },

  mutations: {
    SET_URL: (state, url) => {
      state.url = url;
    },
    SET_PAGE_DES: (state, obj) => {
      state.pageDes = obj;
    }
  },
  actions: {
    GetArticleList: function({ commit }, option) {
      return new Promise((resolve, reject) => {
        getArticleList(option).then(response => {
          resolve(response);
        }).catch(error => {
          reject(error)
        })
      })
    },
    GetArticleDetail: function({ commit }, option) {
      return new Promise((resolve, reject) => {
        getArticleDetail(option).then(response => {
          commit('SET_PAGE_DES', response.data);
          resolve(response);
        }).catch(error => {
          reject(error)
        })
      })
    },
  }
}

export default share
